package com.thiswhyme.log.core;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;

/**
 * @Description: 日志事件listener
 * Created by thiswhyme on 2020/10/11
 */
@Slf4j
public class LogListener implements ApplicationListener<LogEvent> {

    @Async("defaultExecutor")
    @Override
    public void onApplicationEvent(LogEvent logEvent) {
        log.info(JSONUtil.toJsonStr(logEvent.getMsg()));
        //do other things
    }
}